import junit.framework.Assert;
import junit.framework.TestCase;


public class TestInsert extends TestCase {
	  
	//Name: testGeneral()
	//Description: This test checks the following conditions to be true for the insert method:
	//				1) When inserting multiple nodes into empty list, the list has expected amount of nodes
	//				2) The nodes are inserted at the right location within the list
	//				3) The nodes contain the right data integer
	// 				4) When inserting nodes into list that already has nodes in it, the insert method should not break
	// Note: I added a method to the LinkedList class called getNodeForList(). I inserted this so that I can grab the start up node.
	public void testGeneral()
	{
		//Initializing
		LinkedList ll = new LinkedList();
		int nodeData = 0;
		int numberOfNodes = 1;
		int numberOfElementsInList = 2;
		int temp = 0;
		int shouldBeCurrentData = 0;
		
		//Insert elements to list
		while(numberOfElementsInList != 0)
		{
			ll.insert(nodeData);
			nodeData = nodeData + 1;
			numberOfElementsInList = numberOfElementsInList - 1;
		}
		
		Node node = ll.getNodeForList();
		//loop through list
		while(node.getNext() != null) {
			  temp = node.getData();
			  assertTrue(temp == shouldBeCurrentData);
			  node = node.getNext();
			  numberOfNodes = numberOfNodes + 1;
			  shouldBeCurrentData = shouldBeCurrentData + 1;
		  }
		//do the same getData check one more time for the last node
		temp = node.getData();
		assertTrue(temp == shouldBeCurrentData);
		numberOfElementsInList = 2;				//this resets data from while loop above
				
		assertTrue(numberOfNodes == numberOfElementsInList);
	}
}
	
	
